package org.example.common.core.controller;

import cn.hutool.core.collection.CollectionUtil;
import com.github.pagehelper.PageInfo;

import org.example.common.core.model.Result;
import org.example.common.core.model.TableDataInfo;

import java.util.List;

/**
 * @author : [Pashm]
 * @version : [v1.0]
 */

public class BaseController {
    public Result<Void> toResult(Integer rows) {
       return rows > 0 ? Result.ok() : Result.fail();
    }

    public Result<Void> toResult(Boolean rows) {
       return rows ? Result.ok() : Result.fail();
    }

    public TableDataInfo getTableDataInfo(List<?> list){
        if(CollectionUtil.isNotEmpty(list)){
            return TableDataInfo.empty();
        }
        return TableDataInfo.success(list, new PageInfo<>(list).getTotal());//调整
    }

}
